package taskqueue;

import java.lang.management.ManagementFactory;

public class TaskQueueDemo {

    public static void main(String[] args) {

        String name = ManagementFactory.getRuntimeMXBean().getName();
        System.out.println(name);

        TaskQueue queue = new TaskQueue("192.168.0.132", "name", new MessageConsumer() {
            @Override
            public void handle(String task) {
                System.out.println(name + ", handle task=" + task);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        queue.start();

        for (int i = 0; i < 10; i++) {
            queue.add(name + ", create task " + i);
        }

    }

}
